package com.tianyuan.dplrf.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;

import com.hjq.base.BaseAdapter;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.app.AppAdapter;
import com.tianyuan.dplrf.ui.bean.Nczd_zdbean;
import com.tianyuan.dplrf.ui.bean.ZdshowBean;
import com.xuexiang.xutil.display.DensityUtils;

public class Nczd_zddetAdapter extends AppAdapter<ZdshowBean> {

    int with;
    public Nczd_zddetAdapter(@NonNull Context context) {
        super(context);
        with = DensityUtils.getScreenWidth()/6;
    }

    @NonNull
    @Override
    public BaseAdapter<?>.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyHolder();
    }

    private final class MyHolder extends ViewHolder{
        private AppCompatTextView tv_ncname;
        private FrameLayout frameLayout;

        public MyHolder() {
            super(R.layout.item_nczddetlayout);
            tv_ncname = getItemView().findViewById(R.id.tv_ncname);
            frameLayout = getItemView().findViewById(R.id.frame_content);
        }

        @Override
        public void onBindView(int position) {
            tv_ncname.setText(getItem(position).getName());
            frameLayout.setLayoutParams(new ViewGroup.LayoutParams(with,with));
//            tv_ncname.setBackgroundColor(getResources().getColor(getItem(position).isBuystate()? R.color.red : R.color.btn_back));
            frameLayout.setEnabled(getItem(position).isBuystate()? false : true);

        }

    }
}
